{% extends 'base/base_table.html' %}

{% block title %}ITAdmin |监控({{ table_title }}){% endblock %}


{% block table_thead %}
<tr>
    <th>监控项</th>
    <th>数值</th>
</tr>
{% endblock %}

{% block table_bady %}
{% for object in objects %}
<tr>
    <td>{{ object.name }}</td>
    <td id="{{ object.itemid }}">{{ object.lastvalue }}</td>
</tr>
{% endfor %}
{% endblock %}

{% block script %}
    <script>
        function get_info() {
            $.post("{% url 'getitems' %}", {hostid: '{{ hostid }}'}, function (data) {
                var items = JSON.parse(data.items);
                var len = items.length;
                for (var i=0;i<len;i++) {
                    $('#' + items[i].itemid).text(items[i].lastvalue);
                }
            }, 'json');
        }

        function cront() {　
            get_info()
            setTimeout("cront()", 50000);
        }

        $(document).ready(function() {
            cront()
        });

        $(function () {
            $('#pages').val('{{ entry }}')
            $('#pages').change(function () {
                    var search = '{{ search }}'
                    if (search == '') {
                        location.href = "{{ request.path }}?page={{ num }}&entry=" + $(this).val();
                    } else {
                        location.href = "{{ request.path }}?page={{ num }}&{{ search }}&entry=" + $(this).val();
                    }
            });
        })
    </script>
{% endblock %}